﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.ACTP.Components;

namespace ASPNETVN.PORTAL.Modules.ACTP.Controls
{
    public partial class ProjectCalendar : ModulePage
    {

        protected string GetCalendarString()
        {
            string jqueryCalendar = string.Empty;
            IList<Task> tasks = Task.SelectCollectionBy_ProjectID(this.ModuleID, this.ItemID);
            foreach (Task task in tasks)
            {
                jqueryCalendar += "{" + string.Format("id: {7}, title: '{0}', start: new Date({1}, {2}, {3}), end: new Date({4}, {5}, {6})", task.TaskID + " - " + task.Subject, task.StartDate.Year, task.StartDate.Month - 1, task.StartDate.Day, task.DueDate.Year, task.DueDate.Month - 1, task.DueDate.Day, task.TaskID) + "},";
            }

            if (jqueryCalendar.LastIndexOf(",") > 0)
            {
                jqueryCalendar = jqueryCalendar.Remove(jqueryCalendar.LastIndexOf(","), 1);
            }
            return jqueryCalendar;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                // Project Detail Control.
                ProjectDetailControl1.ProjectID = this.ItemID;
            }
        }
    }
}